#ifndef CL_SINGLETON_H
#define CL_SINGLETON_H

#pragma once

template <class T>
class CL_Singleton
{
private:
	CL_Singleton(void) {}
	CL_Singleton(const CL_Singleton&);
	CL_Singleton& operator=(const CL_Singleton&);

public:
	static T* instance()
	{
		if( !m_instance )
			m_instance = new T;
		return m_instance;
	}

	static void destroy()
	{
		if( m_instance )
		{
			delete m_instance;
			m_instance = 0;
		}
	}

private:
	static T* m_instance;
};

#define CL_SINGLETON_INIT(T) T* CL_Singleton<T>::m_instance = 0

#endif // CL_SINGLETON_H